﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Text;
using System.Data;

/// <summary>
/// Summary description for ThongtinController
/// </summary>
public class ThongtinController: Ketnoi
{
    #region[ThongTinATM_Insert]
    public void ThongTinATM_Insert(Thongtin data)
    {
        using (SqlCommand cmd = new SqlCommand("ThongTinATM_Insert", GetConnection()))
        {
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@MaATM", data.MaATM));
            cmd.Parameters.Add(new SqlParameter("@MaKhuvuc", data.MaKhuvuc));
            cmd.Parameters.Add(new SqlParameter("@TenmayATM", data.TenmayATM));
            cmd.Parameters.Add(new SqlParameter("@Diachi", data.Diachi));
            cmd.Parameters.Add(new SqlParameter("@Latitude", data.Latitude));
            cmd.Parameters.Add(new SqlParameter("@Longtitude", data.Longtitude));
            cmd.Parameters.Add(new SqlParameter("@ThongTin", data.ThongTin));
            cmd.Parameters.Add(new SqlParameter("@IsActive", data.IsActive));

            cmd.ExecuteNonQuery();
        }
    }
    #endregion
    //private SqlConnection GetConnection()
    //{
     //   throw new NotImplementedException();
    //}
    

    #region[ThongTinATM_Update]
    public void ThongTinATM_Update(Thongtin data)
    {
        using (SqlCommand cmd = new SqlCommand("ThongTinATM_Update", GetConnection()))
        {
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@MaATM", data.MaATM));
            cmd.Parameters.Add(new SqlParameter("@MaKhuvuc", data.MaKhuvuc));
            cmd.Parameters.Add(new SqlParameter("@TenmayATM", data.TenmayATM));
            cmd.Parameters.Add(new SqlParameter("@Diachi", data.Diachi));
            cmd.Parameters.Add(new SqlParameter("@Latitude", data.Latitude));
            cmd.Parameters.Add(new SqlParameter("@Longtitude", data.Longtitude));
            cmd.Parameters.Add(new SqlParameter("@ThongTin", data.ThongTin));
            cmd.Parameters.Add(new SqlParameter("@IsActive", data.IsActive));

            cmd.ExecuteNonQuery();
        }
    }
    #endregion

    #region[ThongTinATM_Delete]
    public void ThongTinATM_Delete(string MaATM)
    {
        using (SqlCommand cmd = new SqlCommand("ThongTinATM_Delete", GetConnection()))
        {
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@MaATM", MaATM));
            cmd.ExecuteNonQuery();
        }
    }
    #endregion

    #region[ThongTinATM_GetByAll]
    public DataTable ThongTinATM_GetByAll()
    {
        using (SqlCommand cmd = new SqlCommand("ThongTinATM_GetByAll", GetConnection()))
        {
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            return dt;
        }
    }
    #endregion

    #region[ThongTinATM_GetById]
    public DataTable ThongTinATM_GetById(string MaATM)
    {
        using (SqlCommand cmd = new SqlCommand("ThongTinATM_GetById", GetConnection()))
        {
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@MaATM", MaATM));
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            DataTable dt = new DataTable();
            da.Fill(dt);
            return dt;
        }
    }
    #endregion


    #region[ThongTinATM_GetByTop]
    public DataTable ThongTinATM_GetByTop(string Top, string Where, string Order)
    {
        using (SqlCommand cmd = new SqlCommand("ThongTinATM_GetByTop", GetConnection()))
        {
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@Top", Top));
            cmd.Parameters.Add(new SqlParameter("@Where", Where));
            cmd.Parameters.Add(new SqlParameter("@Order", Order));
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            return dt;
        }
    }
    #endregion
    #region[ThongTinATM_GetByMakhuvuc]
    public DataTable ThongTinATM_GetByMakhuvuc()
    {
        using (SqlCommand cmd = new SqlCommand("ThongTinATM_GetByMakhuvuc", GetConnection()))
        {
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            return dt;
        }
    }
    #endregion
	public ThongtinController()
	{
		//
		// TODO: Add constructor logic here
		//
	}
}